package com.example.statistics.ui.yw

import com.example.statistics.bean.DefineInputBean
import com.example.statistics.bean.yw.MaterialBean
import com.example.statistics.net.UrlConfig
import com.example.statistics.utils.Constants
import java.lang.reflect.Type

class MaterialEditActivity : MaterialAddActivity() {

    override val url: String
        get() = UrlConfig.MATERIAL_UPDATE

    override fun data(list: List<DefineInputBean>): List<DefineInputBean> {
        (intent.getSerializableExtra(Constants.DATA) as MaterialBean?)?.let { data ->
            extentParams.add("ID" to data.ID)
            list.forEach {
                it.labelValue = when (it.labelKey) {
                    "date" -> data.date
                    "materialName" -> data.materialName
                    "specification" -> data.specification.toString()
                    "materialNumber" -> data.materialNumber.toString()
                    "materialWeight" -> data.materialWeight.toString()
                    "checkoutNumber" -> data.checkoutNumber.toString()
                    "checkoutWeight" -> data.checkoutWeight.toString()
                    "inventoryNumber" -> data.inventoryNumber.toString()
                    "inventoryWeight" -> data.inventoryWeight.toString()
                    "unitPrice" -> data.unitPrice.toString()
                    "totalPrice" -> data.totalPrice.toString()
                    "checkoutPrice" -> data.checkoutPrice.toString()
                    "freight" -> data.freight.toString()
                    "otherPrice" -> data.otherPrice.toString()
                    "remark" -> data.remark.toString()
                    else -> ""
                }
            }
        }
        return list
    }


    override fun genericType(): Type {
        return MaterialBean::class.java
    }
}